{  Statement: http://acmp.ru/?main=task&id_task=297
   Verdict: Accepted
}
uses
    SysUtils, Math;

var
    i,ls,ans:longint;
    s:string;

begin
reset(input, 'input.txt');
rewrite(output, 'output.txt');
readln(s);
ans := 0;
ls := length(s);
for i := 1 to ls do 
    if s[i] in ['0','6','9'] then inc(ans) else
    if s[i] = '8' then inc(ans, 2);
write(ans);
end.